<?php
namespace Crm\Table;

use Zend\Db\Sql\Select;
use Zend\Db\Sql\Where;

class OrderitemTable extends AbstractTable
{
    protected $table = 'hy_orderitem';
    protected $id = 'oi_id';
    
    public function getOrderitemList($query = array())
    {
        $select = new Select(array('o' =>$this->getTable()));

        if(!empty($query['order_id'])) {
            $select->where(array('order_id' => $query['order_id']));
        }
         
        $select->order('o.order_id DESC');
                 
        $rowset = $this->selectWith($select);
        $list = $rowset->toArray();
    
        return $list;
    }
    
    public function findAllByOrderId($order_id)
    {
        $select = $this->select(array(
            'order_id' => $order_id
        ));
        $result = $select->toArray();
        return $result;
    }
}